//
//  VideoPlayViewController.m
//  LOL视频播放
//
//  Created by 花花蔡 on 2016/12/12.
//  Copyright © 2016年 com.HuaHuaCai. All rights reserved.
//

#import "VideoPlayViewController.h"
#import <AVKit/AVKit.h>
#import <AVFoundation/AVFoundation.h>
#import "SRVideoPlayer.h"

@interface VideoPlayViewController ()<SRVideoPlayerDelegate>

@property (nonatomic, strong) SRVideoPlayer *videoPlayer;


@end

@implementation VideoPlayViewController

- (instancetype)init
{
    self = [super init];
    if (self) {
        
    }
    return self;
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [UIApplication sharedApplication].statusBarHidden = YES;
}

-(void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [UIApplication sharedApplication].statusBarHidden = NO;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.navigationController setNavigationBarHidden:YES animated:YES];
//    UIImageView *imageV = [[UIImageView alloc] initWithFrame:[UIScreen mainScreen].bounds];
//    imageV.image = [UIImage imageNamed:@"register"];
//    [self.view addSubview:imageV];
    self.view.backgroundColor = [UIColor colorWithRed:240/255.0 green:235/255.0 blue:213/255.0 alpha:1];;
    
    [self showVideoPlayer];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

//设置状态栏前景颜色为白色，背景颜色为黑色
//- (UIStatusBarStyle)preferredStatusBarStyle {
//    return UIStatusBarStyleLightContent;
//}

#pragma mark - 播放
- (void)showVideoPlayer {
    
    UIView *playerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.width)];
    playerView.center = self.view.center;
    [self.view addSubview:playerView];
    NSURL *url = [NSURL URLWithString:_urlStr];
    _videoPlayer = [SRVideoPlayer playerWithVideoURL:url playerView:playerView playerSuperView:playerView.superview];
    //_videoPlayer.videoName = @"Here Is The Video Name";
    _videoPlayer.playerEndAction = SRVideoPlayerEndActionStop;
    _videoPlayer.delegate = self;
    [_videoPlayer play];
}

- (void)viewDidDisappear:(BOOL)animated {
    
    [super viewWillDisappear:animated];
    
    [_videoPlayer destroyPlayer];
}

-(void)dismissVc {

    [self dismissViewControllerAnimated:true completion:nil];
}

@end
